'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-11-03 14:33:05
'''
#
# @lc app=leetcode.cn id=880 lang=python3
#
# [880] 索引处的解码字符串
#

# @lc code=start
class Solution:
    def decodeAtIndex(self, S: str, K: int) -> str:
        ans = ''
        for s in S:
            if '0'<=s<='9':
                tmp = int(s)-1
                tmps = ans
                while tmp:
                    ans += tmps
                    tmp-=1
            else:
                ans += s
            if len(ans)>=K:
                return ans[K-1]
# @lc code=end

